package com.atguigu.gmall.product.controller;

import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.product.service.FileUploadService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @Author:lyd
 * @Date:2023/8/15 23:57
 * @Version:1.0
 * @Description
 **/
@RestController
public class FileUploadController {

    @Autowired
    FileUploadService fileUploadService;

    @PostMapping("/admin/product/fileUpload")
    public Result fileUpload(@RequestPart("file") MultipartFile file) throws Exception {
        String path=fileUploadService.upload(file);
        return Result.ok(path);
    }
}
